package com.haodou.util.widget;


import com.penton.util.R;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.drawable.NinePatchDrawable;
import android.util.AttributeSet;
import android.view.View;
/**
 * 索引条（飞信）待修
 * @author pengjianbo <pengjianbosoft@gmail.com>
 *
 */
public class RapidView extends View
{
  private static final int SPACE_RIGHT = 5;
  private Paint.Align align = Paint.Align.CENTER;
  private int count = 27;
  private boolean isTouch = false;
  private NinePatchDrawable localBitmap = null;
  private Context mContext = null;
  private float yPosStart = 0.0F;

  public RapidView(Context paramContext)
  {
    super(paramContext);
    this.mContext = paramContext;
    this.localBitmap = ((NinePatchDrawable)this.mContext.getResources().getDrawable(R.drawable.scroller_bg));
  }

  public RapidView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    this.mContext = paramContext;
    this.localBitmap = ((NinePatchDrawable)this.mContext.getResources().getDrawable(R.drawable.scroller_bg));
  }

  public RapidView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    this.mContext = paramContext;
    this.localBitmap = ((NinePatchDrawable)this.mContext.getResources().getDrawable(R.drawable.scroller_bg));
  }

  protected void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
    Paint localPaint = new Paint();
    localPaint.setAntiAlias(true);
    localPaint.setColor(-254279681);
    localPaint.setStyle(Paint.Style.FILL);
    float f2 = getHeight() - 10;
    localPaint.setColor(-6974059);
    float f1 = 5.0F * f2 / 6.0F / this.count;
    localPaint.setTextSize(f1);
    localPaint.setTextAlign(this.align);
    float f3 = (f2 - f1 * this.count) / (this.count - 1);
    if (this.isTouch)
    {
      this.localBitmap.setBounds(new Rect(getWidth() - (int)f1 - 6 - 5, 0, getWidth() - 5, getHeight()));
      this.localBitmap.draw(paramCanvas);
    }
    for (int i = 0; ; ++i)
    {
      if (i >= 27)
      {
        if (this.isTouch)
          invalidate(new Rect(getWidth() - (int)f1 - 6 - 5, 0, getWidth() - 5, getHeight()));
        return;
      }
      String str;
      if (i != 26)
        str = String.valueOf((char)(i + 65));
      else
        str = "#";
      paramCanvas.drawText(str, getWidth() - f1 / 2.0F - 3.0F - 5.0F, (i + 1) * (f1 + f3), localPaint);
    }
  }

  public void setTouch(boolean paramBoolean)
  {
    this.isTouch = paramBoolean;
  }

  public void setYposStart(float paramFloat)
  {
    this.yPosStart = paramFloat;
  }
}